const user = require("../../mongodb/models/user");

async function Demo(ctx,next){

    console.log("ctx.body:"+ctx.request.query.userName)
    console.log("ctx.body:"+ctx.request.query.passWord)
    try{
        let demoUser= new user({
            name:"大爷",
            age:18,
            sex:"男",
        });
        let Nb = await user.create(demoUser);
        console.log(Nb);
    }catch(err){
        console.log(err.message);
    }
    ctx.body={
        code:200,
        msg:"Demo"
    }
}

async function DemoPost(ctx,next){

    console.log("ctx.body:"+JSON.stringify(ctx.request.body) )
    console.log("ctx.body:"+ctx.request.body.userName)
    console.log("ctx.body:"+ctx.request.body.passWord)
    try{
        let demoUser= new user({
            name:"大爷",
            age:18,
            sex:"男",
        });
        let Nb = await user.create(demoUser);
        console.log(Nb);
    }catch(err){
        console.log(err.message);
    }
    ctx.body={
        code:200,
        msg:"DemoPost"
    }
}

module.exports = {
    Demo,
    DemoPost,
};